﻿using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
using MasterDetailTemplate.Models;

namespace MasterDetailTemplate.Services
{
    /// <summary>
    /// 菜品存储类
    /// </summary>
    public interface IDietStorageService
    {
        /// <summary>
        /// 初始数据库
        /// </summary>
        /// <returns></returns>
        Task InitializeAsync();

        /// <summary>
        /// 数据库时候初始化
        /// </summary>
        /// <returns></returns>
        bool IsInitialized();

        /// <summary>
        /// 根据id查找菜品
        /// </summary>
        /// <param name="dietId">诗词id</param>
        /// <returns></returns>
        Task<Diet> GetDietAsync(int dietId);

        /// <summary>
        /// 根据条件获取菜品列表
        /// </summary>
        /// <param name="where"></param>
        /// <param name="skip"></param>
        /// <param name="take"></param>
        /// <returns></returns>
        Task<List<Diet>> GetDietsAsync(
            Expression<Func<Diet, bool>> where, int skip, int take);

        Task CloseConnection();
    }

    public static class DietStorageConstants {
        public const int VERSION = 1;
        public const int DEFAULTVERSION = -1;

        public const string VersionKey =
            nameof(DietStorageConstants) + "." + nameof(VERSION);
    }
}
